package com.yizhu.zczy.user.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


import com.yizhu.zczy.common.utils.PageUtils;
import com.yizhu.zczy.common.utils.R;
import com.yizhu.zczy.user.vo.NewMemberVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yizhu.zczy.user.entity.UserlevelEntity;
import com.yizhu.zczy.user.service.UserlevelService;


/**
 * 会员等级表
 *
 * @author guoyz
 * @email guoyz@mail.com
 * @date 2021-06-24 18:36:29
 */
@RestController
@RequestMapping("user/userlevel")
public class UserlevelController {
    @Autowired
    private UserlevelService userlevelService;


    @GetMapping("/getMembersAddYesterdayAndToday")
    @ApiOperation("获取昨天今天新增的会员")
    public R getMembersAddYesterdayAndToday(){
        List<NewMemberVo> newMemberVos=userlevelService.getMembersAddYesterdayAndToday();
        return R.ok().setData(newMemberVos);
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("user:userlevel:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userlevelService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{levelId}")
    //@RequiresPermissions("user:userlevel:info")
    public R info(@PathVariable("levelId") Integer levelId){
		UserlevelEntity userlevel = userlevelService.getById(levelId);

        return R.ok().put("userlevel", userlevel);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("user:userlevel:save")
    public R save(@RequestBody UserlevelEntity userlevel){
		userlevelService.save(userlevel);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("user:userlevel:update")
    public R update(@RequestBody UserlevelEntity userlevel){
		userlevelService.updateById(userlevel);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("user:userlevel:delete")
    public R delete(@RequestBody Integer[] levelIds){
		userlevelService.removeByIds(Arrays.asList(levelIds));

        return R.ok();
    }

}
